package com.etc.iodemo;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author: knowno
 * @create: 2024-09-11 17:02
 * @Version 1.0
 **/
public class TestFileReader {
    public static void main(String[] args) throws IOException {

        String filepath = "d:\\demo\\demo.txt";

        //1 FileReader对象的创建
        FileReader fileReader = new FileReader(filepath);


        //2 调用方法 : 长度定义为多少？
        File file = new File(filepath);

        char[] array = new char[(int) file.length()];

        fileReader.read(array);

        //输出
        System.out.println(new String(array));


        //3 关闭
        fileReader.close();

    }
}
